#pragma once

#include "sql/operator/physical_operator.h"
#include "sql/stmt/select_stmt.h"

class AggrePhysicalOperator : public PhysicalOperator
{
public:
    AggrePhysicalOperator( const std::vector<Aggre> &all_aggres)
        : all_aggres_(all_aggres)
    {}

    virtual ~AggrePhysicalOperator() = default;

    PhysicalOperatorType type() const override
    {
        return PhysicalOperatorType::AGGRE;
    }

    RC open(Trx *trx) override;
    RC next() override;
    RC close() override;

    int cell_num() const
    {
        return tuple_.cell_num();
    }

    Tuple *current_tuple() override;

private:
    std::vector<Aggre> all_aggres_;
    ValueListTuple tuple_;
    std::vector<Value> values_;
    int is_read_ = 0;
};